package com.liu.yuoj.model.enums;

import cn.hutool.core.util.StrUtil;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author 刘渠好
 * @since 2025-01-15 22:03
 * 判题信息枚举类
 */
@Getter
public enum JudgeInfoMessageEnum {

    ACCEPT("成功", "Accepted"),
    WRONG_ANSWER("答案错误", "Wrong Answer"),
    COMPILE_ERROR("编译错误", "Compile Error"),
    MEMORY_LIMIT_EXCEEDED("内存溢出", "Memory Limit Exceeded"),
    TIME_LIMIT_EXCEEDED("超时", "Time Limit Exceeded"),
    PRESENTATION_ERROR("展示错误", "Presentation Error"),
    WAITING("等待中","Waiting"),
    OUTPUT_LIMIT_EXCEEDED("输出溢出", "Output Limit Exceeded"),
    DANGEROUS_OPERATION("危险操作", "Dangerous Operation"),
    RUNTIME_ERROR("运行错误", "Runtime Error"),
    SYSTEM_ERROR("系统错误", "System Error");

    private String text;

    private String value;

     JudgeInfoMessageEnum(String text, String value) {
        this.text = text;
        this.value = value;
    }

    //根据value查看枚举值
    public JudgeInfoMessageEnum getEnumByValue(String value) {
        if (StrUtil.isBlank (value)){
            return null;
        }
        //遍历
        for (JudgeInfoMessageEnum e : JudgeInfoMessageEnum.values()) {
            if (e.getValue ().equals(value)){
                return e;
            }
        }
        return null;
    }

    /**
     * 返回枚举值集合
     * @return
     */
    public List<String> getValues() {
        return Arrays.stream (values ()).map (JudgeInfoMessageEnum::getValue).collect(Collectors.toList());
    }

}
